package com.lemon.smartsafety.ui.adapter.hidden.main;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.lemon.smartsafety.entity.hidden.HiddenMainUIVo;
import com.lemon.smartsafety.entity.hidden.MainHiddenUIItemBase;
import com.lemon.smartsafety.listener.RecyclerTClickListener;
import com.lemon.smartsafety.ui.adapter.common.RcvViewType;
import com.lemon.smartsafety.ui.adapter.common.SectionHeadView;

import java.util.List;

import kale.adapter.LemonRcvAdapter;
import kale.adapter.item.AdapterItem;

/**
 * Created by Cooliean on 16/2/22.
 */
public class HiddenMainAdapter extends LemonRcvAdapter<MainHiddenUIItemBase<HiddenMainUIVo>> {
    private RecyclerTClickListener<MainHiddenUIItemBase<HiddenMainUIVo>> mListener;

    public enum HiddenMainUITag {
        /** 隐患周期 */
        TAG_CYCLE,
        /** 已上报隐患个数 */
        TAG_REPORT_COUNT,
        /** 零隐患上报 */
        TAG_ZERO,
        /** 隐患上报 */
        TAG_UPLOAD_REPORT,
        /** 隐患整改 */
        TAG_MODIFY_HIDDEN;
    }


    public HiddenMainAdapter(@Nullable List<MainHiddenUIItemBase<HiddenMainUIVo>> data, RecyclerTClickListener<MainHiddenUIItemBase<HiddenMainUIVo>> listener) {
        super(data);
        mListener = listener;
    }

    private HiddenMainAdapter(@Nullable List<MainHiddenUIItemBase<HiddenMainUIVo>> data) {
        super(data);
    }


    @Override
    public Object getItemType(MainHiddenUIItemBase<HiddenMainUIVo> data) {
        return data.getViewType();
    }


    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        RcvViewType.CommonRcvViewType data = (RcvViewType.CommonRcvViewType) type;
        if (data == RcvViewType.CommonRcvViewType.TYPE_SECTION_HEAD) {
            return new SectionHeadView();
        }
        return new HiddenMainItem(mListener);
    }
}
